<?php
class Cms_Model_Comment
{
	private static $_instance;
	private static $_cacheTimeout = 300;
	
	private function __construct() {
	}
	
	/**
	 * @return Cms_Model_Comment
	 * */
	public static function factory() {
		if(self::$_instance == null) {
			self::$_instance = new self();
		}
		
		return self::$_instance;
	}
	
	public function insert($data) {
	    if(!$data['username'] || !$data['comment'] || !$data['course_id']) {
	        return 0;
	    }
	    $result = 0;
	    try {
	        $dao = Cms_Model_DAO_Comment::factory();
	        $result = $dao->insert($data);
	    } catch (Exception $exc) {
	        prBinh($exc);
	        Utils_Global::storeLog($exc, __FILE__, __LINE__ );
	    }
	    
	    return $result;
	}
	
	public function select($options = array()) {
	    $result = array();
	    try {
	        $dao = Cms_Model_DAO_Comment::factory();
	        $result = $dao->select($options);
	    } catch (Exception $exc) {
	        prBinh($exc);
	        Utils_Global::storeLog($exc, __FILE__, __LINE__);
	    }
	    
	    return $result;
	}
	
	public function count($options = array()) {
	    $result = array();
	    try {
	    	$dao = Cms_Model_DAO_Comment::factory();
	    	$result = $dao->count($options);
	    } catch (Exception $exc) {
	    	prBinh($exc);
	    	Utils_Global::storeLog($exc, __FILE__, __LINE__);
	    }
	     
	    return $result;
	}
}